<!--
 * @Description: 
 * @Author: your name
 * @version: 
 * @Date: 2023-12-26 14:27:43
 * @LastEditors: your name
 * @LastEditTime: 2023-12-26 14:27:45
-->
<template>
    <div class="tableHead">
        <span class="headItem" v-for="(item, index) in columns" :key="index" :step="1">
            {{ item }}
        </span>
    </div>
    <vue3-seamless-scroll :list="list" class="scroll" :hover="true">
        <div class="item" v-for="(item, index) in list" :key="index">
            <span>
                <div :class="itemType(item)">
                    {{ item.type }}
                </div>
            </span>
            <span>{{ item.title }}</span>
            <span>{{ item.content }}</span>
            <span>{{ item.time }}</span>
        </div>
    </vue3-seamless-scroll>
</template>
<script setup>
import { ref } from "vue";
import { Vue3SeamlessScroll } from "vue3-seamless-scroll";
const data = []
for (let i = 0; i < 100; i++) {
    data.push({
        type: '正常',
        title: "智慧社区",
        content: '停水停电',
        time: '2022-05-01'
    })
}
const cols = ['报警类型', '报警区域', '报警内容', '报警时间']
const list = ref(data);
const columns = ref(cols);
const classTypes = [
    {
        type: '正常',
        class: 'normal'
    }, {
        type: '封控',
        class: 'diable'
    }, {
        type: '报警',
        class: 'warn'
    }
]
const itemType = (item) => {
    const res = {
        'itemType': true,
    }
    const target = classTypes.find(c => c.type === item.type)
    if (target) {
        res[target.class] = true
    }
    return res
}
</script>
  
<style lang="scss">
.tableHead {
    width: 100%;
    height: 30px;
    font-size: 12px;
    display: flex;
    align-items: center;
    padding-left: 10px;

    .headItem {
        flex: 1;
        color: rgba(232, 232, 240, 0.7)
    }
}

.scroll {
    height: 150px;
    width: 100%;
    overflow: hidden;
    margin-top: 10px;
    margin-bottom: 10px;
    padding-left: 10px;
}

.itemType {
    width: 53px;
    height: 25px;
    border-radius: 2px;
    background-blend-mode: normal;
    text-align: center;
    line-height: 24px;
    color: #54e2a9;
    background: #54e2a933;
}

.normal {
    color: #54e2a9;
    background: #54e2a933;
}

.diable {
    color: #bfbfbf;
    background: #bfbfbf33;
}

.warn {
    color: #e04236;
    background: #e0423633;
}

.scroll .item {
    display: flex;
    align-items: center;
    font-size: 12px;
    height: 40px;

    >span {
        flex: 1;
        display: inline-block;
        max-width: 25%;
        overflow: hidden;
        color: #fff;
    }
}
</style>
  